Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous UI/config refactoring #134

Merged
merged 3 commits into from
Mar 27, 2024

Conversation

throwaway96
Copy link
Member

  • Centralized information about the config options (such as descriptions) in config.js. This allowed me to replace the hardcoded options panel with a semi-automatically generated one. (There is not yet a way to specify that options are grouped, like the SponsorBlock sub-options are.) Now a config option can be added just by editing the data structure in config.js and adding one line in ui.js (which will hopefully no longer be necessary soon).
  • Made the configuration stuff a bit stricter. Exceptions will now be thrown when trying to read/write unknown options (which shouldn't be happening anyway). Changes to localConfig no longer affect defaultConfig.
  • Moved the logic for checking whether a code is a color button into its own function. You can now call getKeyColor(evt.charCode), which will return e.g. 'green' for code 404 (or null if it's not a color button).
  • Separated out the code to show and hide the options panel into its own function. It's exposed as ytaf_showOptionsPanel() for use via the console, which makes remote debugging much more convenient.

I started calling the green button screen the "options panel" since uiContainer isn't a very descriptive name. I'm open to other suggestions, though.

@throwaway96 throwaway96 force-pushed the refactoring-20240324 branch from fefc326 to c2295d1 Compare March 25, 2024 04:31
@throwaway96 throwaway96 added this to the v0.3.3 milestone Mar 25, 2024
Centralize all information about configuration options in a single
object. Replace hardcoded options UI with programmatic generation based
on descriptions in config.js. Also throw exceptions on invalid config
keys and stop changes to localConfig from affecting defaultConfig.

Ideally the options UI would be entirely automatically generated, but a
way a way to handle grouped options (like the SponsorBlock ones) is
still needed.

It is now easier to add a config option, and hopefully soon it will only
require adding an entry to configOptions in config.js.
Provide a function for decoding rather than using raw character codes.
The new function is available globally as ytaf_showOptionsPanel() for
console use.
@throwaway96 throwaway96 merged commit ea029f0 into webosbrew:main Mar 27, 2024
1 check passed
throwaway96 added a commit that referenced this pull request Mar 27, 2024
Miscellaneous UI/config refactoring

Plus a last-minute fix for one of my mistakes
throwaway96 added a commit that referenced this pull request Mar 27, 2024
Miscellaneous UI/config refactoring

Plus a last-minute fix for one of my mistakes
throwaway96 added a commit to throwaway96/youtube-webos that referenced this pull request Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants